<!DOCTYPE html>
<html lang="en">
  <body>
    <!--标题-->
    <div>JavaScript<span>进阶</span></div>

    <script>
      function getParents(el) {
        if (typeof el !== "object" || el === null) {
          throw new Error("el应该是一个对象");
        }
        let _el = el;
        const result = [];
        while (_el.__proto__ !== null) {
          result.push(_el.__proto__.constructor.name);
          _el = _el.__proto__;
        }
        return result;
      }
      console.log(getParents(document));
      console.log(getParents(document.createElement("div")));
      console.log(getParents(new Text("云牧")));
    </script>
  </body>
</html>
